﻿
namespace BEGDC.PreContract.DAL
{
    using System;
    using System.Collections.Generic;
    using Castle.ActiveRecord;
    using NHibernate.Expression;


    [ActiveRecord]
    public partial class Product : ActiveRecordBase<Product>
    {
		#region Const Definition
		
		public const string CONST_ProductID								= "ProductID";
		public const string CONST_ProductName							= "ProductName";
		public const string CONST_Description							= "Description";
		public const string CONST_Quantity								= "Quantity";
		public const string CONST_UnitID								= "UnitID";

		#endregion
		
        #region Member Variables
        // Primary Key
        private System.Int32 _productID;
        
        // Non Key
        private System.String _productName;
        private System.String _description;
        private Nullables.NullableDecimal _quantity;

        // Parents
        private DicItem _unitID;
        
        
		

        #endregion

        public Product() {
               
        }
        public Product(
            System.String productName
            ,System.String description
            ,Nullables.NullableDecimal quantity) : this() {
                
            this._productName = productName; 
            this._description = description; 
            this._quantity = quantity; 
        }
        
        #region Properties
        // Primary Key        
		
		#if (SQLServer)
        [PrimaryKey]
		#else
		[PrimaryKey(PrimaryKeyType.Native, SequenceName = "SEQ_PRODUCT_PRODUCTID")]
		#endif
        public System.Int32 ProductID {
            get { return this._productID; }
            set {  this._productID = value; }
        }
        
        // Non Key
        [Property]
        public System.String ProductName {
            get { return this._productName; }
			set { if (value == null) return; if (value.Length > 200) this._productName = value.Substring(0,200); else this._productName = value; }	
        }
        
        [Property]
        public System.String Description {
            get { return this._description; }
			set { if (value == null) return; if (value.Length > 500) this._description = value.Substring(0,500); else this._description = value; }	
        }
        
        [Property]
        public Nullables.NullableDecimal Quantity {
            get { return this._quantity; }
			set { this._quantity = value; }
        }
        
        
        // Parent Relationships
        [BelongsTo("UnitID")]
        public DicItem UnitID {
            get { return this._unitID; }
            set { this._unitID = value; }
        }
        
        // Child Relationships
        
		
        #endregion
		
		// Clone
		public Product Clone()
		{
			Product newProduct = new Product();
			
            newProduct.ProductName = this._productName; 
            newProduct.Description = this._description; 
            newProduct.Quantity = this._quantity; 
            newProduct.UnitID = this._unitID ; 
			return newProduct;
		}
    }
}



